<?php

declare(strict_types=1);

namespace App\Model\Ocpc;

use Hyperf\DbConnection\Model\Model;

/**
 *  OcpcBaiduLog
 */
class OcpcBaiduLog extends Model
{
    protected $table = 'ocpc_baidu_log';

    const PKG = [
        408 => 'com.xylx.wchat'
    ];

    static function addLog($params = [])
    {
        $m = new self();
        $m->url = $params['url'] ?? '';
        $m->pay_amount = $params['pay_amount'] ?? 0;
        $m->sign = $params['sign'];
        $m->res = $params['res'];
        $m->type = $params['type'];
        $m->user_id = $params['user_id'] ?? 0;
        $m->channel = $params['channel'];
        $m->pkg = $params['pkg'];
        $m->akeys = $params['akeys'] ?? '';
        return $m->saveOrFail() ? 1 : 0;
    }
}